package com.hzc.springchan.service.impl;

import com.hzc.springchan.mapper.EnvironmentCheckMapper;
import com.hzc.springchan.service.IEnvironmentCheckService;
import com.hzc.springchan.util.LogUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 环境检查服务类
 * @author chen990627
 * @date 2022/10/13
 */
@Service("environmentCheckService")
public class EnvironmentCheckServiceImpl implements IEnvironmentCheckService {

    @Autowired
    private EnvironmentCheckMapper environmentCheckMapper;

    @Override
    public void healthCheck() {

        // datasource check
        LogUtils.info(this, "datasource check start");
        try {
            environmentCheckMapper.dual();
        } catch (Exception e) {
            System.out.println(e);
            LogUtils.error("datasource check fail: ", e.getStackTrace());
            System.exit(-1);
        }
        LogUtils.info(this, "datasource check success");
    }
}
